package com.glory.dgcpcpda.activity.cpc;

import android.content.Intent;
import android.util.Log;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.adapter.StripIdListAdapter;
import com.glory.dgcpcpda.base.BaseActivity;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;

import butterknife.BindView;

public class WforMaterialViewActivity extends BaseActivity {
    @BindView(R.id.llMain)
    LinearLayout llMain;

    @BindView(R.id.rvMaterilaList)
    RecyclerView rvMaterilaList;


    private StripIdListAdapter suggestListAdapter;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_wformaterilaview;
    }

    @Override
    protected void initView() {
        setMainLayout(llMain);
    }

    @Override
    protected void initData() {
        initRecyclerView(rvMaterilaList,this);
        suggestListAdapter = new StripIdListAdapter(null);
        suggestListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        suggestListAdapter.isFirstOnly(true);
        rvMaterilaList.setAdapter(suggestListAdapter);
        ArrayList<String> list = new ArrayList<>();
        Intent intent = getIntent();
        String item = intent.getStringExtra("item");

        if (StringUtils.isNoneEmpty(item)){
            if(item.contains("|")){
                String[] parts = item.split("\\|");
                list = new ArrayList<>(Arrays.asList(parts));
            }
            else {
                list.add(item);
            }
            suggestListAdapter.setNewData(list);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
